﻿
namespace Mulala.Cavan.Presentation.Seedwork
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.Contracts;
    using System.Linq;
    using Mulala.Cavan.Core.Extension;

    /// <summary>
    ///     Base model for any controller using default UI infrastructure (MasterPage)
    /// </summary>
    public abstract class WebModel : CoreModel, IWebModel
    {
        #region members
        IMasterModel _masterModel;
        #endregion members

        public IMasterModel MasterModel 
        {
            get { return _masterModel ?? (_masterModel = ModelFactory.CreateModel<IMasterModel>(Messages)); }
            set
            {
                Contract.Requires(value.Is(), " Cannot set the Model to null! Provide an instance of IMasterModel ");
                _masterModel = value;
            }
        }

    }
}